<template>
    <div class="page-banner">
        <div class="left" @contextmenu.prevent="openScenarioForm($event)">
            <p class="title">场景列表</p>
            <ul>
                <li
                        v-for="(item, index) in options.scenario"
                        :key="index"
                        :class="{
						active: item.id == selects.scenarioId
					}"
                        @click="changeScenario(item.id)"
                        @contextmenu.prevent.stop="openScenarioForm($event, item)"
                >{{ item.name }}</li>
            </ul>
        </div>

        <!--风控配置-->
        <cl-crud class="right" @load="onLoadParams" v-if="selects.scenarioId === 1" key="1">
            <template #table-column-shareIconDisplay="{scope}">
                <el-tag type="danger" v-if="scope.row.shareIconDisplay == 0">隐藏</el-tag>
                <el-tag v-if="scope.row.shareIconDisplay == 1">显示</el-tag>
            </template>
            <template #table-column-status="{scope}">
                <el-tag type="danger" v-if="scope.row.status == 0">禁用</el-tag>
                <el-tag v-if="scope.row.status == 1">启用</el-tag>
            </template>
        </cl-crud>

        <!--小气泡配置-->
        <cl-crud class="right" @load="onLoadBubble" v-if="selects.scenarioId === 2" key="2">
            <template #slot-filter>
                <div class="nav base-flex">
                    <div class="nav-li" style="margin-left: 10px">
                        <date-picker
                                @change="
								val => crud.refresh({ startTime: val[0], endTime: val[1], page: 1 })
							"
                                @refresh="crud.refresh({ startTime: '', endTime: '', page: 1 })"
                        ></date-picker>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">状态：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="状态"
                                v-model="selects.status"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ status: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="隐藏" :value="0"></el-option>
                            <el-option label="显示" :value="1"></el-option>
                        </el-select>
                    </div>
                </div>
            </template>
            <template #slot-btn>
                <el-button type="danger" size="mini" @click="batchStatus(0)" :disabled="selectRow.length > 0 ? false : true">批量隐藏</el-button>
                <el-button type="primary" size="mini" @click="batchStatus(1)" :disabled="selectRow.length > 0 ? false : true">批量显示</el-button>
            </template>
            <template #table-column-status="{scope}">
                <el-tag type="danger" v-if="scope.row.status == 0">隐藏</el-tag>
                <el-tag v-if="scope.row.status == 1">显示</el-tag>
            </template>
            <template #table-column-type="{scope}">
                <el-tag v-if="scope.row.type == 1">商品链接</el-tag>
                <el-tag v-if="scope.row.type == 2">小程序链接</el-tag>
            </template>
        </cl-crud>

        <!--金刚位、5G权益-->
        <cl-crud
                class="right"
                @load="onLoadBanner"
                v-if="selects.scenarioId === 5 || selects.scenarioId === 6"
                key="56"
        >
            <template #slot-filter>
                <div class="nav base-flex">
                    <div class="nav-li" style="margin-left: 10px">
                        <date-picker
                                @change="
								val => crud.refresh({ startTime: val[0], endTime: val[1], page: 1 })
							"
                                @refresh="crud.refresh({ startTime: '', endTime: '', page: 1 })"
                        ></date-picker>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">状态：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="状态"
                                v-model="selects.status"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ status: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="隐藏" value="close"></el-option>
                            <el-option label="显示" value="open"></el-option>
                        </el-select>
                    </div>
                </div>
            </template>
            <template #table-column-pick="{scope}">
                <el-image fit="fill" :src="scope.row.pick" style="height: 50px"></el-image>
            </template>

            <template #table-column-status="{scope}">
                <el-tag type="danger" v-if="scope.row.status == 'close'">隐藏</el-tag>
                <el-tag v-if="scope.row.status == 'open'">显示</el-tag>
            </template>
        </cl-crud>

        <!--每日抢红包-->
        <cl-crud class="right" @load="onLoadRed" v-if="selects.scenarioId === 4" key="4">
            <template #slot-filter>
                <div class="nav base-flex">
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">状态：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="状态"
                                v-model="selects.status"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ status: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="隐藏" :value="0"></el-option>
                            <el-option label="显示" :value="1"></el-option>
                        </el-select>
                    </div>
                </div>
            </template>
            <template #table-column-status="{scope}">
                <el-tag type="danger" v-if="scope.row.status == 0">隐藏</el-tag>
                <el-tag v-if="scope.row.status == 1">显示</el-tag>
            </template>
            <template #table-column-hour="{scope}">
                <div>{{ (scope.row.hour).toString().length == 2 ? `${scope.row.hour}:00` : `0${scope.row.hour}:00`}}</div>
            </template>
        </cl-crud>

        <!--兑红包配置-->
        <cl-crud class="right" @load="onLoadRedChange" v-if="selects.scenarioId === 3" key="3">
            <template #slot-filter>
                <div class="nav base-flex">
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">状态：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="状态"
                                v-model="selects.status"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ status: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="隐藏" :value="0"></el-option>
                            <el-option label="显示" :value="1"></el-option>
                        </el-select>
                    </div>
                </div>
            </template>
            <template #table-column-status="{scope}">
                <el-tag type="danger" v-if="scope.row.status == 0">隐藏</el-tag>
                <el-tag v-if="scope.row.status == 1">显示</el-tag>
            </template>
        </cl-crud>

        <!--抽奖配置-->
        <cl-crud class="right" @load="onLoadLottery" v-if="selects.scenarioId === 8" key="8">
            <template #slot-filter>
                <div class="nav base-flex">
                    <div class="nav-li" style="margin-left: 10px">
                        <date-picker
                                @change="
								val => crud.refresh({ startTime: val[0], endTime: val[1], page: 1 })
							"
                                @refresh="crud.refresh({ startTime: '', endTime: '', page: 1 })"
                        ></date-picker>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">状态：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="请选择状态"
                                v-model="selects.isOpened"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ isOpened: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="进行中" :value="0"></el-option>
                            <el-option label="已开奖" :value="1"></el-option>
                        </el-select>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">类型：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="请选择类型"
                                v-model="selects.type"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ type: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="按人数开奖" :value="1"></el-option>
                            <el-option label="按时间开奖" :value="2"></el-option>
                        </el-select>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">兑奖状态：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="请选择兑奖状态"
                                v-model="selects.status"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ status: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="未兑奖" :value="0"></el-option>
                            <el-option label="已兑奖" :value="1"></el-option>
                        </el-select>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <el-button type="text" class="set-wechat" @click="setWechat()">客服微信设置</el-button>
                    </div>
                </div>
            </template>
            <template #slot-operate="{scope}">
                <div class="cursor">
                    <div @click="lotteryDetail(scope.row)">查看统计</div>
                    <div @click="lotteryChange(scope.row)" v-if="scope.row.isOpened === 1">兑奖</div>
                    <div @click="lotteryCopy(scope.row)">复制</div>
                </div>
            </template>
            <template #table-column-condition="{scope}">
                <p v-if="scope.row.type == 1">{{ scope.row.userCount }}人</p>
                <p v-if="scope.row.type == 2">开奖时间<br>{{ scope.row.endTime }}</p>
            </template>
            <template #table-column-isOpened="{scope}">
                <el-tag type="success" v-if="scope.row.isOpened == 0">进行中</el-tag>
                <el-tag type="warning" v-if="scope.row.isOpened == 1">已开奖</el-tag>
            </template>
            <template #table-column-status="{scope}">
                <el-tag v-if="scope.row.status == 0">未兑奖</el-tag>
                <el-tag type="info" v-if="scope.row.status == 1">已兑奖</el-tag>
            </template>
        </cl-crud>

        <!--打卡配置-->
        <cl-crud class="right" @load="onLoadPunch" v-if="selects.scenarioId === 9" key="9">
            <template #slot-filter>
                <div class="nav base-flex">
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">打卡时长：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="请选择打卡时长"
                                v-model="selects.type"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ type: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="1日赛" :value="1"></el-option>
                            <el-option label="2日赛" :value="2"></el-option>
                            <el-option label="3日赛" :value="3"></el-option>
                            <el-option label="7日赛" :value="7"></el-option>
                        </el-select>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <span style="font-size: 14px">状态：</span>
                        <el-select
                                size="mini"
                                filterable
                                placeholder="请选择状态"
                                v-model="selects.status"
                                style="margin-right: 10px;width:120px;"
                                @change="val => refresh({ status: val, page: 1 })"
                        >
                            <el-option value label="全部"></el-option>
                            <el-option label="未开始" :value="0"></el-option>
                            <el-option label="进行中" :value="1"></el-option>
                            <el-option label="已结束" :value="2"></el-option>
                        </el-select>
                    </div>
                    <div class="nav-li" style="margin-left: 10px">
                        <date-picker
                                @change="
								val => crud.refresh({ startTime: val[0], endTime: val[1], page: 1 })
							"
                                @refresh="crud.refresh({ startTime: '', endTime: '', page: 1 })"
                        ></date-picker>
                    </div>
                </div>
            </template>
            <template #slot-operate="{scope}">
                <div class="cursor">
                    <div @click="punchDetail(scope.row)">查看统计</div>
                    <div @click="punchCopy(scope.row)">复制</div>
                </div>
            </template>
            <template #table-column-time="{scope}">
                {{ scope.row.startTime }} - {{ scope.row.endTime }}
            </template>
            <template #table-column-status="{scope}">
                <el-tag v-if="scope.row.status == 0">未开始</el-tag>
                <el-tag type="success" v-if="scope.row.status == 1">进行中</el-tag>
                <el-tag type="info" v-if="scope.row.status == 2">已结束</el-tag>
            </template>
        </cl-crud>

        <!--签到配置-->
        <cl-crud class="right" @load="onLoadSign" v-if="selects.scenarioId === 10" key="10">
            <template #table-column-status="{scope}">
                <el-tag type="danger" v-if="scope.row.status == 0">禁用</el-tag>
                <el-tag v-if="scope.row.status == 1">启用</el-tag>
            </template>
        </cl-crud>

        <!--公告配置-->
        <cl-crud class="right" @load="onLoadNotice" v-if="selects.scenarioId === 11" key="11">
            <template #table-column-isDisplay="{scope}">
                <el-tag type="danger" v-if="scope.row.isDisplay == 0">隐藏</el-tag>
                <el-tag v-if="scope.row.isDisplay == 1">显示</el-tag>
            </template>
        </cl-crud>

        <!--配置关联-->
        <cl-crud class="right" @load="onLoadSync" v-if="selects.scenarioId === 7" key="7">
            <template #slot-sync>
                <el-button type="danger" size="mini" @click="syncParams()" v-if="(platForm === '5gqy' && !platformVal) || platformVal === '5gqy'">同步配置</el-button>
            </template>
        </cl-crud>

        <cl-context-menu ref="scenario-context-menu"></cl-context-menu>
        <cl-form ref="scenario-form"></cl-form>
        <cl-form ref="cl-form"></cl-form>
    </div>
</template>

<script>
	import moment from 'moment';
	import DatePicker from '@/components/common/date-picker';
	import { mapGetters } from 'vuex';
	import store from 'store';
	import RedProbability from './components/RedProbability';
	import fileList from './components/feilList';
	import LotteryDetail from './components/LotteryDetail'
	import PunchDetail from './components/PunchDetail'
	export default {
		components: {
			RedProbability,
			DatePicker,
			fileList
		},
		data() {
			return {
				crud: null,
				selects: {
					status: '',
					scenarioId: 1,
					type: '',
					isOpened: ''
				},
				options: {
					scenario: [
						{
							id: 1,
							key: 'fk',
							name: '风控配置'
						},
						{
							id: 2,
							key: 'xqp',
							name: '小气泡配置'
						},
						{
							id: 5,
							key: 'jgw',
							name: '金刚位配置'
						},
						{
							id: 4,
							key: 'mrqhb',
							name: '每日抢红包配置'
						},
						{
							id: 6,
							key: '5gqy',
							name: '5G权益配置'
						},
						{
							id: 3,
							key: 'dhb',
							name: '兑红包配置'
						},
						{
							id: 8,
							key: 'cj',
							name: '抽奖配置'
						},
						{
							id: 9,
							key: 'dk',
							name: '打卡配置'
						},
						{
							id: 10,
							key: 'qd',
							name: '签到配置'
						},
						{
							id: 11,
							key: 'gg',
							name: '公告配置'
						},
						{
							id: 7,
							key: 'pzgl',
							name: '配置关联'
						},
					],
					userList: [
						{ label: '又有小鸡来偷能量了！', value: 2088702830763271 },
						{ label: '水淋淋羊姜', value: 2088502855393631 },
						{ label: '韶华钦负', value: 2088212572694633 },
						{ label: '我就是我', value: 2088632892725688 },
						{ label: 'Flan', value: 2088802002992954 },
						{ label: '庄树增', value: 2088412582874735 },
					]
				},
				platForm: null,
				selectRow: [],
				signList: [],
				signObject: {},
				pickerOptions: {
					disabledDate(time) {
						return time.getTime() < Date.now();
					}
				},
			};
		},
		created() {
			this.platForm = store.get('platForm');
		},
		computed: {
			...mapGetters(['platformList', 'platformVal']),
		},
		methods: {
			onLoadParams({ ctx, app }) {
				ctx.service(this.$service.interactiveSoft.hdyxRiskSetting)
					.set('table', {
						columns: [
							{
								type: 'index',
								label: '序号',
								align: 'center'
							},
							{
								label: '步数起兑门槛',
								prop: 'lowerLimit',
								align: 'center'
							},
							{
								label: '步数兑换上限',
								prop: 'upperLimit',
								align: 'center'
							},
							{
								label: '步数',
								prop: 'probability',
								align: 'center'
							},
							{
								label: '金币',
								prop: 'goldAmount',
								align: 'center'
							},
							{
								label: '步数清零时间',
								prop: 'time',
								align: 'center',
								span: 12,
								component: {
									name: 'el-time-select',
									'value-format': 'HH:mm',
									props: {
										'picker-options': {
											start: '00:00',
											step: '01:00',
											end: '23:00'
										}
									}
								}
							},
							{
								label: '分享奖励次数',
								prop: 'shareCount',
								align: 'center'
							},
							{
								label: '分享奖励金币',
								prop: 'shareDeservedGoldAmount',
								align: 'center'
							},
							{
								label: '分享奖励图标',
								prop: 'shareIconDisplay',
								align: 'center'
							},
							{
								label: '打卡服务费比例%',
								prop: 'serviceRate',
								align: 'center'
							},
							{
								label: '步数兑换抽奖券上限',
								prop: 'exchangelimit',
								align: 'center'
							},
							{
								label: '分享得抽奖券上限',
								prop: 'sharelimit',
								align: 'center'
							},
							{
								label: '步数兑券比',
								prop: 'needStepNum',
								align: 'center'
							},
							{
								label: '金币兑券比',
								prop: 'needGoldAmount',
								align: 'center'
							},
							{
								label: '状态',
								prop: 'status',
								align: 'center'
							},
						]
					})
					.set('upsert', {
						props: {
							width: '750px',
							labelWidth: '160px'
						},
						items: [
							{
								label: '步数起兑门槛：',
								prop: 'lowerLimit',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入步数起兑门槛'
									}
								},
								rules: {
									required: true,
									message: '请输入步数起兑门槛'
								}
							},
							{
								label: '步数兑换上限：',
								prop: 'upperLimit',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入步数兑换上限'
									}
								},
								rules: {
									required: true,
									message: '请输入步数兑换上限'
								}
							},
							{
								label: '步数兑金币比：',
								prop: 'probability',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '步数（例：1000）'
									}
								},
								rules: {
									required: true,
									message: '请输入金币兑换比例'
								}
							},
							{
								label: '比:',
								prop: 'goldAmount',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '金币（例：10）'
									}
								},
								rules: {
									required: true,
									message: '请输入金币'
								}
							},
							{
								label: '步数清零时间：',
								prop: 'time',
								align: 'center',
								span: 16,
								value: '00:00',
								component: {
									name: 'el-time-select',
									'value-format': 'HH:mm',
									props: {
										'picker-options': {
											start: '00:00',
											step: '01:00',
											end: '23:00'
										},
										placeholder: '清零时间'
									}
								}
							},
							{
								label: '分享奖励次数：',
								prop: 'shareCount',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入奖励次数'
									}
								},
								rules: {
									required: true,
									message: '请输入奖励次数'
								}
							},
							{
								label: '分享奖励金币:',
								prop: 'shareDeservedGoldAmount',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入奖励金币'
									}
								},
								rules: {
									required: true,
									message: '请输入奖励金币'
								}
							},
							{
								label: '分享奖励图标：',
								prop: 'shareIconDisplay',
								span: 14,
								component: {
									name: 'el-select',
									props: {
										placeholder: '请选择隐藏/显示',
										clearable: true,
									},
									options: [
										{
											label: '隐藏',
											value: 0
										},
										{
											label: '显示',
											value: 1
										}
									]
								},
								rules: {
									required: true,
									message: '请选择隐藏/显示'
								}
							},
							{
								label: '打卡服务费比例%:',
								prop: 'serviceRate',
								span: 16,
								value: 0,
								component: {
									name: 'el-input-number',
									attrs: {
										placeholder: '请输入打卡服务费比例',
										precision: 2,
										min: 0,
										max: 100
									}
								},
								rules: {
									required: true,
									message: '请输入打卡服务费比例'
								}
							},
							{
								label: '步数兑换抽奖券上限:',
								prop: 'exchangelimit',
								span: 16,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入步数兑换抽奖券上限'
									}
								},
								rules: {
									required: true,
									message: '请输入步数兑换抽奖券上限'
								}
							},
							{
								label: '分享得抽奖券上限:',
								prop: 'sharelimit',
								span: 16,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入分享得抽奖券上限'
									}
								},
								rules: {
									required: true,
									message: '请输入分享得抽奖券上限'
								}
							},
							{
								label: '步数兑券比:',
								prop: 'needStepNum',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '一张抽奖券需要多少步数'
									}
								},
								rules: {
									required: true,
									message: '请输入步数兑券比'
								}
							},
							{
								label: '金币兑券比:',
								prop: 'needGoldAmount',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '一张抽奖券需要多少金币'
									}
								},
								rules: {
									required: true,
									message: '请输入金币兑券比'
								}
							},
							{
								label: '状态：',
								prop: 'status',
								span: 24,
								value: 1,
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '启用',
											value: 1
										},
										{
											label: '禁用',
											value: 0
										}
									]
								},
								rules: {
									required: true,
									message: '请选择状态'
								}
							},
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {
						// if (isEdit) {
						// 	app.setData('upsert.items[prop:time].value', [data.startTime, data.endTime]);
						// }
					})
					.on('submit', (isEdit, data, { next }) => {
						next({
							...data
						});
					})
					.done();

				app.refresh();
				this.crud = app;
			},
			onLoadBubble({ ctx, app }) {
				this.selectRow = [];
				ctx.service(this.$service.interactiveSoft.bubbleSetting)
					.set('table', {
						columns: [
							{
								type: 'selection',
								align: 'center'
							},
							{
								label: '名称',
								prop: 'name',
								align: 'center'
							},
							{
								label: '跳转链接',
								prop: 'jumpUrl',
								align: 'center'
							},
							{
								label: '类型',
								prop: 'type',
								align: 'center'
							},
							{
								label: '金币数',
								prop: 'goldAmount',
								align: 'center'
							},
							{
								label: '排序',
								prop: 'level',
								align: 'center',
								sortable: 'custom'
							},
							{
								label: '浏览定时',
								prop: 'timing',
								align: 'center'
							},
							{
								label: '开始时间',
								prop: 'startTime',
								align: 'center'
							},
							{
								label: '结束时间',
								prop: 'endTime',
								align: 'center'
							},
							{
								label: '状态',
								prop: 'status',
								align: 'center'
							}
						],
						op: {
							layout: ['edit']
						},
						on: {
							'selection-change': selection => {
								this.selectRow = selection;
							}
						}
					})
					.set('upsert', {
						props: {
							width: '550px',
							labelWidth: '120px'
						},
						items: [
							{
								label: '气泡名称',
								prop: 'name',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入气泡名称'
									}
								},
								rules: {
									required: true,
									message: '请输入气泡名称'
								}
							},
							{
								prop: 'type',
								label: '类型：',
								value: 2,
								component: {
									name: 'el-select',
									props: {
										placeholder: '请选择活动类型',
										clearable: true,
										disabled: true
									},
									options: [
										{
											label: '商品链接',
											value: 1
										},
										{
											label: '小程序链接',
											value: 2
										}
									]
								},
								rules: [
									{
										required: true,
										message: '请选择活动类型',
										trigger: 'blur'
									}
								]
							},
							{
								label: '跳转链接',
								prop: 'jumpUrl',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入跳转链接'
									}
								},
								rules: {
									required: true,
									message: '请输入跳转链接'
								}
							},
							{
								label: '金币数',
								prop: 'goldAmount',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入金币数'
									}
								},
								rules: {
									required: true,
									message: '请输入金币数'
								}
							},
							{
								prop: 'level',
								label: '排序：',
								span: 24,
								component: {
									name: 'el-input',
									attrs: {
										size: 'mini',
										placeholder: '请输入排序'
									}
								},
								rules: {
									required: true,
									message: '请输入排序',
									trigger: 'blur'
								}
							},
							{
								prop: 'timing',
								label: '浏览定时：',
								span: 12,
								value: 10,
								component: {
									name: 'el-select',
									props: {
										clearable: true
									},
									options: [
										{
											label: '0秒',
											value: 0
										},
										{
											label: '5秒',
											value: 5
										},
										{
											label: '10秒',
											value: 10
										},
										{
											label: '15秒',
											value: 15
										},
										{
											label: '20秒',
											value: 20
										}
									]
								},
								rules: {
									required: true,
									message: '请选择浏览定时',
									trigger: 'blur'
								}
							},
							{
								prop: 'time',
								label: '显示时间：',
								span: 24,
								component: {
									name: 'el-date-picker',
									attrs: {
										type: 'daterange',
										'value-format': 'yyyy-MM-dd',
										'start-placeholder': '开始日期',
										'end-placeholder': '结束日期'
									}
								},
								rules: [
									{
										required: true,
										message: '请选择活动时间',
										trigger: 'blur'
									}
								]
							},
							{
								prop: 'status',
								label: '状态：',
								value: 1,
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '隐藏',
											value: 0
										},
										{
											label: '显示',
											value: 1
										}
									]
								},
								rules: [
									{
										required: true,
										message: '请选择活动时间',
										trigger: 'blur'
									}
								]
							}
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'slot-btn', 'slot-filter', 'flex1', 'search-key'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {
						if (isEdit) {
							app.setForm('time', [
								data.startTime,
								data.endTime
							])
						} else {
							app.setForm('time', [])
						}
					})
					.on('submit', (isEdit, data, { next }) => {
						const startTime = moment(data.time[0]).format('YYYY-MM-DD 00:00:00');
						const endTime = moment(data.time[1]).format('YYYY-MM-DD 23:59:59');
						delete data.time;
						next({
							...data,
							startTime,
							endTime
						});
					})
					.done();

				app.refresh({
					scenarioId: this.selects.scenarioId
				});
				this.crud = app;
			},
			onLoadBanner({ ctx, app }) {
				ctx.service(this.$service.systemMenagement.banner)
					.set('table', {
						columns: [
							{
								type: 'index',
								label: '序号',
								align: 'center'
							},
							{
								label: '标题',
								prop: 'title',
								align: 'center'
							},
							{
								label: '图片',
								prop: 'pick',
								align: 'center',
								width: 400
							},
							{
								label: '跳转链接',
								prop: 'link',
								align: 'center'
							},
							{
								label: '状态',
								prop: 'status',
								align: 'center'
							},
							{
								label: '排序',
								prop: 'level',
								align: 'center',
								sortable: 'custom'
							},
							{
								label: '备注',
								prop: 'remark',
								align: 'center',
								emptyText: '无'
							},
							{
								label: '创建时间',
								prop: 'createTime',
								align: 'center'
							}
						],
						op: {
							layout: ['edit']
						}
					})
					.set('upsert', {
						props: {
							width: '700px',
							labelWidth: '100px'
						},
						items: [
							{
								label: '轮播图高度',
								prop: 'imageSize',
								span: 15,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入图片高度'
									},
									on: {
										change(val) {
											app.setData(
												'upsert.items[prop:pick].component.props.size',
												val
											);
										}
									}
								}
							},
							{
								label: '图片地址',
								prop: 'pick',
								component: {
									name: 'cl-upload',
									props: {
										height: '126px',
										width: '355px',
										isLimit: true,
										size: ''
									}
								},
								rules: {
									required: true,
									message: '图片地址不能为空'
								}
							},
							{
								label: '跳转链接',
								prop: 'link',
								component: {
									name: 'el-input'
								},
								rules: {
									required: true,
									message: '跳转链接不能为空'
								}
							},
							{
								label: '标题',
								prop: 'title',
								component: {
									name: 'el-input'
								},
								rules: {
									required: true,
									message: '标题不能为空'
								}
							},
							{
								label: '场景',
								prop: 'scenarioId',
								component: {
									name: 'el-select',
									options: [
										{ value: 5, label: '金刚位' },
										{ value: 6, label: '5G权益' }
									],
									attrs: {
										disabled: true
									}
								},
								rules: {
									required: true,
									message: '场景不能为空'
								}
							},
							{
								label: '排序',
								prop: 'level',
								component: {
									name: 'el-input'
								},
								rules: {
									required: true,
									message: '排序不能为空'
								}
							},
							{
								label: '备注',
								prop: 'remark',
								component: {
									name: 'el-input'
								}
							},
							{
								label: '状态',
								prop: 'status',
								value: 'open',
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '启用',
											value: 'open'
										},
										{
											label: '禁用',
											value: 'close'
										}
									]
								},
								rules: {
									required: true,
									message: '状态不能为空'
								}
							},
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'slot-filter', 'flex1', 'search-key'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {
						if (this.selects.scenarioId) {
							app.setForm('scenarioId', this.selects.scenarioId);
						}

						const list = await this.$service.systemMenagement.bannerScenario.list();
						app.setData('upsert.items[prop:pick].component.props.size', data.imageSize);
						app.setData(
							'upsert.items[prop:scenarioId].component.options',
							list.map(e => {
								return {
									label: e.name,
									value: e.id
								};
							})
						);
					})
					.on('submit', (isEdit, data, { next }) => {
						next({
							...data
						});
					})
					.done();

				app.refresh({});
				this.crud = app;
			},
			onLoadRed({ ctx, app }) {
				ctx.service(this.$service.interactiveSoft.robMoney)
					.set('table', {
						columns: [
							{
								label: '序号',
								type: 'index',
								align: 'center'
							},
							// {
							// 	label: '开抢时间点',
							// 	prop: 'hour',
							// 	align: 'center',
							// 	component: {
							// 		name: 'el-time-select',
							// 		'value-format': 'HH:mm',
							// 		props: {
							// 			'picker-options': {
							// 				start: '00:00',
							// 				step: '01:00',
							// 				end: '23:00'
							// 			}
							// 		}
							// 	}
							// },
							{
								label: '个数',
								prop: 'limitNum',
								align: 'center'
							},
							{
								label: '金币数',
								prop: 'money',
								align: 'center'
							},
							{
								label: '状态',
								prop: 'status',
								align: 'center'
							}
						],
						op: {
							layout: ['edit']
						},
						on: {
							'selection-change': selection => {
								this.selectRow.red = selection;
							}
						}
					})
					.set('upsert', {
						props: {
							width: '550px',
							labelWidth: '120px'
						},
						items: [
							// {
							// 	label: '开抢时间点：',
							// 	prop: 'hour',
							// 	component: {
							// 		name: 'el-time-select',
							// 		'value-format': 'HH:mm',
							// 		props: {
							// 			'picker-options': {
							// 				start: '00:00',
							// 				step: '01:00',
							// 				end: '23:00'
							// 			}
							// 		}
							// 	},
							// 	rules: {
							// 		required: true,
							// 		message: '请选择时间点'
							// 	}
							// },
							{
								label: '个数：',
								prop: 'limitNum',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入个数'
									}
								},
								rules: {
									required: true,
									message: '请输入个数'
								}
							},
							{
								label: '金币数：',
								prop: 'money',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入金币数'
									}
								},
								rules: {
									required: true,
									message: '请输入金币数'
								}
							},
							{
								label: '红包金额：',
								prop: 'value',
								component: RedProbability,
								rules: {
									required: true,
									message: '请输入红包金额和概率'
								}
							},
							{
								label: '状态：',
								prop: 'status',
								value: 1,
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '启用',
											value: 1
										},
										{
											label: '禁用',
											value: 0
										}
									]
								},
								rules: {
									required: true,
									message: '状态不能为空'
								}
							}
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'slot-filter', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {
						if (data && data.hour)
							data.hour =
								data.hour.toString().length == 2
									? `${data.hour}:00`
									: `0${data.hour}:00`;
					})
					.on('submit', (isEdit, data, { next, done }) => {
						let probability = 0;
						if (data.hour) {
							const h = data.hour.split(':');
							data.hour = h[0];
						}
						data.value.forEach(item => {
							if (item.probability) {
								probability = probability + Number(item.probability);
							}
						});
						if (probability !== 1) {
							this.$message.error('总概率需为1');
							done();
							return false;
						}
						data.value = JSON.stringify(data.value);
						next({
							...data,
							surplus: data.limitNum,
							type: 1
						});
					})
					.done();

				app.refresh({
					type: 1
				});
				this.crud = app;
			},
			onLoadRedChange({ ctx, app }) {
				ctx.service(this.$service.interactiveSoft.robMoney)
					.set('table', {
						columns: [
							{
								label: '序号',
								type: 'index',
								align: 'center'
							},
							{
								label: '金币个数',
								prop: 'money',
								align: 'center'
							},
							{
								label: '兑换金额',
								prop: 'value',
								align: 'center'
							},
							{
								label: '每日数量',
								prop: 'limitNum',
								align: 'center'
							},
							{
								label: '排序',
								prop: 'level',
								align: 'center',
								sortable: 'custom'
							},
							{
								label: '状态',
								prop: 'status',
								align: 'center'
							}
						],
						op: {
							layout: ['edit']
						},
						on: {
							'selection-change': selection => {
								this.selectRow.redChange = selection;
							}
						}
					})
					.set('upsert', {
						props: {
							width: '550px',
							labelWidth: '120px'
						},
						items: [
							{
								label: '金币个数：',
								prop: 'money',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入金币个数'
									}
								},
								rules: {
									required: true,
									message: '请输入金币个数'
								}
							},
							{
								label: '兑换金额：',
								prop: 'value',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入兑换金额'
									}
								},
								rules: {
									required: true,
									message: '请输入兑换金额数'
								}
							},
							{
								label: '每日数量：',
								prop: 'limitNum',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入每日数量'
									}
								},
								rules: {
									required: true,
									message: '请输入每日数量'
								}
							},
							{
								label: '排序：',
								prop: 'level',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入排序'
									}
								},
								rules: {
									required: true,
									message: '请输入排序'
								}
							},
							{
								label: '状态：',
								prop: 'status',
								value: 1,
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '启用',
											value: 1
										},
										{
											label: '禁用',
											value: 0
										}
									]
								},
								rules: {
									required: true,
									message: '状态不能为空'
								}
							}
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'slot-filter', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {})
					.on('submit', (isEdit, data, { next }) => {
						next({
							...data,
							surplus: data.limitNum,
							type: 2
						});
					})
					.done();

				app.refresh({
					type: 2
				});
				this.crud = app;
			},
			onLoadLottery({ ctx, app }) {
				let that = this;
				ctx.service(this.$service.interactiveSoft.lotteryActivity)
					.set('table', {
						columns: [
							{
								label: '序号',
								type: 'index',
								align: 'center'
							},
							{
								label: '奖品名称',
								prop: 'name',
								align: 'center'
							},
							{
								label: '数量',
								prop: 'num',
								align: 'center'
							},
							{
								label: '类型',
								prop: 'type',
								align: 'center',
								dict: [
									{
										label: '按人数开奖',
										value: 1
									},
									{
										label: '按时间开奖',
										value: 2
									}
								]
							},
							{
								label: '条件',
								prop: 'condition',
								align: 'center',
								minWidth: 120
							},
							{
								label: '供应商名称',
								prop: 'providerName',
								align: 'center'
							},
							{
								label: '状态',
								prop: 'isOpened',
								align: 'center',
								dict: [
									{
										label: '进行中',
										value: 0
									},
									{
										label: '已开奖',
										value: 1
									}
								]
							},
							{
								label: '创建时间',
								prop: 'createTime',
								align: 'center',
								sortable: 'custom',
								minWidth: 120
							},
							{
								label: '兑奖状态',
								prop: 'status',
								align: 'center',
								dict: [
									{
										label: '未兑奖',
										value: 0
									},
									{
										label: '已兑奖',
										value: 1
									}
								]
							},
							{
								label: '机器人数',
								prop: 'robotUserNumber',
								align: 'center'
							},
							{
								label: '指定用户中奖',
								prop: 'userId',
								align: 'center',
								dict: this.options.userList
							},
						],
						op: {
							layout: ['edit', 'slot-operate']
						},
					})
					.set('upsert', {
						props: {
							width: '1050px',
							labelWidth: '140px'
						},
						items: [
							{
								label: '奖品名称：',
								prop: 'name',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入奖品名称',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '奖品名称不能为空'
								}
							},
							{
								label: '数量：',
								prop: 'num',
								span: 12,
								value: 1,
								component: {
									name: 'el-input-number',
									attrs: {
										placeholder: '请输入奖品数量',
										min: 1,
										precision: 0,
										step: 1
									}
								},
								rules: {
									required: true,
									message: '奖品数量不能为空'
								}
							},
							{
								prop: 'pic',
								label: '奖品图片',
								component: fileList,
								rules: {
									required: true,
									message: '奖品图片不能为空'
								}
							},
							{
								label: '抽奖类型：',
								prop: 'type',
								span: 24,
								value: 1,
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '按人数开奖',
											value: 1
										},
										{
											label: '按时间开奖',
											value: 2
										}
									],
									on: {
										change(val) {
											if (val === 2) {
												app.setData('upsert.items[prop:time].hidden', false);
												app.setData('upsert.items[prop:userCount].hidden', true);
											} else {
												app.setData('upsert.items[prop:time].hidden', true);
												app.setData('upsert.items[prop:userCount].hidden', false);
											}
										}
									}
								},
								rules: {
									required: true,
									message: '请选择抽奖类型'
								},
							},
							{
								label: '人数条件：',
								prop: 'userCount',
								span: 12,
								value: 1,
								hidden: false,
								component: {
									name: 'el-input-number',
									attrs: {
										placeholder: '请输入开奖人数',
										min: 1,
										precision: 0,
										step: 1
									}
								},
								rules: {
									required: true,
									message: '开奖人数不能为空'
								}
							},
							{
								prop: 'time',
								label: '时间条件：',
								span: 12,
								hidden: true,
								component: {
									name: 'el-date-picker',
									attrs: {
										type: 'datetimerange',
										'value-format': 'yyyy-MM-dd HH:mm:ss',
										'start-placeholder': '开始日期',
										'end-placeholder': '结束日期'
									}
								},
								rules: [
									{
										required: true,
										message: '请选择活动时间',
										trigger: 'blur'
									}
								]
							},
							{
								label: '奖品供应商信息：',
								span: 24,
							},
							{
								label: '供应商icon：',
								prop: 'providerIcon',
								span: 8,
								component: {
									name: 'cl-upload',
									props: {
										height: '70px',
										width: '70px',
										isLimit: true,
										size: ''
									}
								},
								rules: {
									required: true,
									message: '供应商icon不能为空'
								}
							},
							{
								label: '供应商名称：',
								prop: 'providerName',
								span: 16,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入供应商名称',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '供应商名称不能为空'
								}
							},
							{
								label: '供应商介绍：',
								prop: 'providerMsg',
								span: 16,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入供应商介绍',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '供应商介绍不能为空'
								}
							},
							{
								label: '链接类型：',
								prop: 'linkType',
								span: 8,
								value: 0,
								component: {
									name: 'el-select',
									props: {
										placeholder: '链接类型',
										clearable: true
									},
									options: [
										{
											label: '小程序',
											value: 0
										},
										{
											label: '生活号',
											value: 1
										},
										{
											label: 'H5',
											value: 2
										}
									]
								},
								rules: {
									required: true,
									message: '链接类型不能为空'
								}
							},
							{
								label: '链接：',
								prop: 'link',
								span: 16,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入链接',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '链接不能为空'
								}
							},
							{
								label: '抽奖详情：',
								prop: 'detailMsg',
								span: 24,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入抽奖详情',
										type: 'textarea',
										clearable: true,
										rows: 6
									}
								},
								rules: {
									required: true,
									message: '抽奖详情不能为空'
								}
							},
							{
								label: '机器人数：',
								prop: 'robotUserNumber',
								span: 12,
								value: 0,
								component: {
									name: 'el-input-number',
									attrs: {
										placeholder: '请输入机器人数',
										min: 0,
										precision: 0,
										step: 1
									}
								},
							},
							{
								label: '指定用户中奖：',
								prop: 'userId',
								span: 12,
								component: {
									name: 'el-select',
									props: {
										placeholder: '请选择中奖用户',
										clearable: true
									},
									options: this.options.userList
								}
							},
							{
								label: '排序：',
								prop: 'level',
								span: 12,
								value: 1,
								component: {
									name: 'el-input-number',
									attrs: {
										placeholder: '请输入排序',
										min: 1,
										precision: 0,
										step: 1
									}
								},
							},
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'slot-filter', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {
						if (isEdit) {
							setTimeout(() => {
								if (data.type === 2) {
									app.setForm('time', [data.startTime , data.endTime]);
									app.setData('upsert.items[prop:time].hidden', false);
									app.setData('upsert.items[prop:userCount].hidden', true);
								} else {
									app.setData('upsert.items[prop:time].hidden', true);
									app.setData('upsert.items[prop:userCount].hidden', false);
								}
                            })
						} else {
							app.setData('upsert.items[prop:time].hidden', true);
							app.setData('upsert.items[prop:userCount].hidden', false);
						}
					})
					.on('submit', (isEdit, data, { next }) => {
						if (data.type === 2) {
							next({
								...data,
								startTime: data.time[0],
								endTime: data.time[1]
							})
						} else {
							next({
								...data,
								startTime: moment().format('YYYY-MM-DD HH:mm:ss')
							})
						}
					})
					// .on('refresh', async (params, { next, render }) => {
					// 	const { list } = await next(params);
					// 	render();
					// })
					.done();

				app.refresh();
				this.crud = app;
			},
			onLoadPunch({ ctx, app }) {
				let that = this;
				ctx.service(this.$service.interactiveSoft.sign)
					.set('table', {
						columns: [
							{
								label: '序号',
								type: 'index',
								align: 'center'
							},
							{
								label: '打卡时长',
								prop: 'type',
								align: 'center',
								dict: [
									{
										label: '1日赛',
										value: 1
									},
									{
										label: '2日赛',
										value: 2
									},
									{
										label: '3日赛',
										value: 3
									},
									{
										label: '7日赛',
										value: 7
									}
								]
							},
							{
								label: '打卡时间',
								prop: 'time',
								align: 'center',
								minWidth: 150
							},
							{
								label: '押金',
								prop: 'amount',
								align: 'center'
							},
							{
								label: '步数条件',
								prop: 'stepNum',
								align: 'center'
							},
							{
								label: '状态',
								prop: 'status',
								align: 'center',
								dict: [
									{
										label: '未开始',
										value: 0
									},
									{
										label: '进行中',
										value: 1
									},
									{
										label: '已结束',
										value: 2
									}
								]
							},
							{
								label: '创建时间',
								prop: 'createTime',
								align: 'center',
								sortable: 'custom',
								minWidth: 120
							},
						],
						op: {
							layout: ['edit', 'slot-operate']
						},
					})
					.set('upsert', {
						props: {
							width: '1050px',
							labelWidth: '140px'
						},
						items: [
							{
								label: '打卡时长：',
								prop: 'type',
								span: 12,
								value: 1,
								component: {
									name: 'el-select',
									props: {
										placeholder: '请输入打卡时长',
										clearable: true
									},
									options: [
										{
											label: '1日赛',
											value: 1
										},
										{
											label: '2日赛',
											value: 2
										},
										{
											label: '3日赛',
											value: 3
										},
										{
											label: '7日赛',
											value: 7
										}
									]
								},
								rules: {
									required: true,
									message: '打卡时长不能为空'
								}
							},
							{
								prop: 'startTime',
								label: '打卡时间：',
								span: 12,
								value: moment().add(1, 'days').format('YYYY-MM-DD'),
								component: {
									name: 'el-date-picker',
									attrs: {
										type: 'date',
										'value-format': 'yyyy-MM-dd',
										'start-placeholder': '开始日期',
										'end-placeholder': '结束日期',
										'picker-options': this.pickerOptions
									},
								},
								rules: [
									{
										required: true,
										message: '请选择活动时间',
										trigger: 'blur'
									}
								]
							},
							{
								label: '押金：',
								prop: 'amount',
								span: 24,
								value: 500,
								component: {
									name: 'el-input-number',
									attrs: {
										placeholder: '请输入打卡押金',
										precision: 0,
										min: 0,
										step: 50,
									}
								},
								rules: {
									required: true,
									message: '打卡押金不能为空'
								}
							},
							{
								label: '步数条件：',
								prop: 'stepNum',
								span: 24,
								value: 5000,
								component: {
									name: 'el-input-number',
									attrs: {
										placeholder: '请输入步数条件',
										precision: 0,
										min: 0,
										step: 100,
									}
								},
								rules: {
									required: true,
									message: '步数条件不能为空'
								}
							},
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'slot-filter', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {
						if (isEdit) {
							app.setForm('time', moment(data.startTime).format('YYYY-MM-DD'));
						}
					})
					.on('submit', (isEdit, data, { next }) => {
						next({
							...data,
							startTime: moment(data.startTime).format('YYYY-MM-DD 00:00:00')
						})
					})
					.done();

				app.refresh();
				this.crud = app;
			},
			onLoadSign({ ctx, app }) {
				let that = this;
				ctx.service(this.$service.interactiveSoft.scoreTask)
					.set('table', {
						columns: [
							{
								label: '序号',
								type: 'index',
								align: 'center'
							},
							{
								label: '第1日金币数',
								prop: 'N1',
								align: 'center'
							},
							{
								label: '第2日金币数',
								prop: 'N2',
								align: 'center'
							},
							{
								label: '第3日金币数',
								prop: 'N3',
								align: 'center'
							},
							{
								label: '第4日金币数',
								prop: 'N4',
								align: 'center'
							},
							{
								label: '第5日金币数',
								prop: 'N5',
								align: 'center'
							},
							{
								label: '第6日金币数',
								prop: 'N6',
								align: 'center'
							},
							{
								label: '第7日金币数',
								prop: 'N7',
								align: 'center'
							},
						],
						op: {
							layout: ['edit']
						},
					})
					.set('upsert', {
						props: {
							width: '850px',
							labelWidth: '140px'
						},
						items: [
							{
								label: '第1日金币数：',
								prop: 'N1',
								span: 8,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '第1日金币数',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入第1日金币数'
								}
							},
							{
								label: '第2日金币数：',
								prop: 'N2',
								span: 8,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '第2日金币数',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入第2日金币数'
								}
							},
							{
								label: '第3日金币数：',
								prop: 'N3',
								span: 8,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '第3日金币数',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入第23日金币数'
								}
							},
							{
								label: '第4日金币数：',
								prop: 'N4',
								span: 8,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '第4日金币数',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入第4日金币数'
								}
							},
							{
								label: '第5日金币数：',
								prop: 'N5',
								span: 8,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '第5日金币数',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入第5日金币数'
								}
							},
							{
								label: '第6日金币数：',
								prop: 'N6',
								span: 8,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '第6日金币数',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入第6日金币数'
								}
							},
							{
								label: '第7日金币数：',
								prop: 'N7',
								span: 8,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '第7日金币数',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入第7日金币数'
								}
							},
						]
					})
					.set('layout', [
						['refresh-btn', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('open', async (isEdit, data) => {
						if (isEdit) {
							app.setForm('N1', this.signObject.N1);
							app.setForm('N2', this.signObject.N2);
							app.setForm('N3', this.signObject.N3);
							app.setForm('N4', this.signObject.N4);
							app.setForm('N5', this.signObject.N5);
							app.setForm('N6', this.signObject.N6);
							app.setForm('N7', this.signObject.N7);
						}
					})
					.on('submit', (isEdit, data, { next }) => {
						if (isEdit) {
							let arr = [];
							this.signList.forEach(item => {
								if (item.key === 'N1') {
									arr.push({
										score: data.N1,
										id: item.id
									});
								}
								if (item.key === 'N2') {
									arr.push({
										score: data.N2,
										id: item.id
									});
								}
								if (item.key === 'N3') {
									arr.push({
										score: data.N3,
										id: item.id
									});
								}
								if (item.key === 'N4') {
									arr.push({
										score: data.N4,
										id: item.id
									});
								}
								if (item.key === 'N5') {
									arr.push({
										score: data.N5,
										id: item.id
									});
								}
								if (item.key === 'N6') {
									arr.push({
										score: data.N6,
										id: item.id
									});
								}
								if (item.key === 'N7') {
									arr.push({
										score: data.N7,
										id: item.id
									});
								}
							});
							next({
								scores: JSON.stringify(arr)
							});
						}
					})
					.on('refresh', async (params, { next, render }) => {
						this.params = params;
						const { list } = await next(params);
						let Arr = [];
						let Object = {};
						list.forEach(item => {
							if (item.key === 'N1') {
								Object.N1 = item.score;
							}
							if (item.key === 'N2') {
								Object.N2 = item.score;
							}
							if (item.key === 'N3') {
								Object.N3 = item.score;
							}
							if (item.key === 'N4') {
								Object.N4 = item.score;
							}
							if (item.key === 'N5') {
								Object.N5 = item.score;
							}
							if (item.key === 'N6') {
								Object.N6 = item.score;
							}
							if (item.key === 'N7') {
								Object.N7 = item.score;
							}
						});
						Arr.push(Object);
						this.signList = list;
						this.signObject = Object;
						render(Arr);
					})
					.done();

				app.refresh();
				this.crud = app;
			},
			onLoadNotice({ ctx, app }) {
				let that = this;
				ctx.service(this.$service.interactiveSoft.announcement)
					.set('table', {
						columns: [
							{
								label: '序号',
								type: 'index',
								align: 'center'
							},
							{
								label: '公告内容',
								prop: 'desc',
								align: 'center'
							},
							{
								label: '赠送金币',
								prop: 'goldAmount',
								align: 'center'
							},
							{
								label: '状态',
								prop: 'isDisplay',
								align: 'center'
							},
							{
								label: '创建时间',
								prop: 'createTime',
								align: 'center'
							},
						],
						op: {
							layout: ['edit', 'delete']
						},
					})
					.set('upsert', {
						props: {
							width: '850px',
							labelWidth: '140px'
						},
						items: [
							{
								label: '公告内容：',
								prop: 'desc',
                                value: '[\n' +
									'    {\n' +
									'            "content": "我是公告标题",\n' +
									'            "textAlign": "center",\n' +
									'            "fontSize": "32",\n' +
									'            "color": "#000000",\n' +
									'            "fontWeight": "600",\n' +
									'            "marginBottom": "20"\n' +
									'     },\n' +
									'    {\n' +
									'            "content": "我是公告内容",\n' +
									'            "textAlign": "left",\n' +
									'            "fontSize": "28",\n' +
									'            "color": "#000000",\n' +
									'            "fontWeight": "400",\n' +
									'            "marginBottom": "0"\n' +
									'     }\n' +
									']',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入公告内容',
										clearable: true,
										type: 'textarea',
                                        rows: 18
									}
								},
								rules: {
									required: true,
									message: '公告内容不能为空'
								}
							},
							{
								label: '赠送金币：',
								prop: 'goldAmount',
								span: 12,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入赠送金币',
										clearable: true
									}
								}
							},
							{
								label: '状态：',
								prop: 'isDisplay',
								value: 1,
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '启用',
											value: 1
										},
										{
											label: '禁用',
											value: 0
										}
									]
								},
								rules: {
									required: true,
									message: '状态不能为空'
								}
							}
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('submit', async (isEdit, data, { next, done }) => {
						let isAward = 0;
						if (Number(data.goldAmount) > 0) {
							isAward = 1;
						}
						next({
							...data,
							isAward: isAward
						});
					})
					.done();

				app.refresh();
				this.crud = app;
			},
			onLoadSync({ ctx, app }) {
				let that = this;
				ctx.service(this.$service.interactiveSoft.appRelevance)
					.set('table', {
						columns: [
							{
								label: '序号',
								type: 'index',
								align: 'center'
							},
							{
								label: '数据平台',
								prop: 'name',
								align: 'center'
							},
							{
								label: 'key',
								prop: 'key',
								align: 'center'
							},
						],
						op: {
							layout: ['edit']
						},
					})
					.set('upsert', {
						props: {
							width: '550px',
							labelWidth: '120px'
						},
						items: [
							{
								label: 'key：',
								prop: 'key',
								span: 22,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入平台标识',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入平台标识'
								}
							},
							{
								span: 2,
								component: {
									name: 'search',
									methods: {
										checkKey() {
											let key = app.getData('upsert.form.key');
											if (!key) {
												that.$message.error('请输入平台标识');
												return false;
											}
											// 执行检索
											let name = null;
											that.platformList.forEach(item => {
												if (item.value === key) {
													name = item.label;
												}
											});
											if (!name) {
												that.$message.error('平台不存在，请重新输入');
												return false;
											}
											app.setForm('name', name);
										}
									},
									render() {
										return (
											<el-button type="text" style="margin-left: -105px" on-click={this.checkKey}>检索</el-button>
									);
									}
								}
							},
							{
								label: '数据平台：',
								prop: 'name',
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请输入数据平台',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '请输入数据平台'
								}
							},
						]
					})
					.set('layout', [
						['refresh-btn', 'add-btn', 'slot-sync', 'flex1'],
						['data-table'],
						['flex1', 'pagination']
					])
					.on('submit', (isEdit, data, { next, done }) => {
						let key = null;
						let name = null;
						that.platformList.forEach(item => {
							if (item.value === data.key) {
								key = item.value;
								name = item.label;
							}
						});
						if (key !== data.key) {
							that.$message.error('平台标识不存在，请重新输入');
							done();
							return false;
						}
						if (name !== data.name) {
							that.$message.error('平台名称有误，请重新输入，或执行检索');
							done();
							return false;
						}

						next({
							...data
						});
					})
					.done();

				app.refresh();
				this.crud = app;
			},
			syncParams() {
				if ((this.platForm === '5gqy' && !this.platformVal) || this.platformVal === '5gqy') {
					this.$service.interactiveSoft.appRelevance.synSettings().then(res => {
						this.$message.success('同步成功');
					})
				} else {
					this.$message.error('请切换至支支权益平台同步');
				}
			},

			batchStatus(status) {
				let ids = [];
				this.selectRow.forEach(item => {
					ids.push(item.id)
				});
				if (!ids.length) {
					this.$message.error('请选择气泡');
					return false
				}
				this.$service.interactiveSoft.bubbleSetting.batchEditStatus({
					ids: ids.join(','),
					status: status
				}).then((res) => {
					this.refresh()
				})
			},

			refresh(params) {
				this.crud.refresh(params);
			},

			changeScenario(id) {
				this.selects.scenarioId = id;
				this.$nextTick(() => {
					if (id == 5 || id == 6) {
						this.crud.refresh({ scenarioId: this.selects.scenarioId });
					} else {
						// this.crud.refresh({ scenarioId: this.selects.scenarioId });
					}
				});
			},

			openScenarioForm(event, data) {
				let list = [];

				if (!data) {
					list = [
						{
							label: '新增',
							'suffix-icon': 'el-icon-plus',
							callback: (item, done) => {
								this.upsertScenario();
								done();
							}
						}
					];
				} else {
					list = [
						{
							label: '编辑',
							'suffix-icon': 'el-icon-edit',
							callback: (item, done) => {
								this.upsertScenario(data);
								done();
							}
						}
					];
				}

				this.$refs['scenario-context-menu'].open(event, {
					list
				});
			},

			upsertScenario(item = {}) {
				this.$refs['scenario-form'].open({
					props: {
						title: '场景编辑',
						width: '500px',
						'label-width': '100px'
					},

					items: [
						{
							label: '场景名称',
							prop: 'name',
							value: item.name,
							component: {
								name: 'el-input',
								attrs: {
									placeholder: '请填写场景名称'
								}
							}
						},
						{
							label: '场景关键字',
							prop: 'key',
							value: item.key,
							component: {
								name: 'el-input',
								attrs: {
									placeholder: '请填写场景关键字'
								}
							}
						}
					],

					on: {
						submit: ({ data, done, close }) => {
							const fn = item.id ? 'update' : 'add';

							this.$service.systemMenagement.bannerScenario[fn]({
								...data,
								id: item.id
							})
								.then(() => {
									this.$message.success('保存成功');
									this.refreshScenario();
									close();
								})
								.catch(err => {
									this.$message.error(err);
									done();
								});
						}
					}
				});
			},

			// 查看统计 兑奖 复制
			lotteryDetail(item) {
				this.$service.interactiveSoft.lotteryActivity.lotteryParticipant({
					id: item.id
				}).then(res => {
					if (res.lotteryParticipant.length > 0) {
						this.$refs['cl-form'].open({
							props: {
								title: '参与明细',
								width: '950px',
								'label-width': '0px'
							},
							items: [
								{
									prop: 'lotteryDetail',
									value: res,
									component: LotteryDetail
								},
							],
						});
					} else {
						this.$message.error('暂无信息')
					}
				});
			},
			lotteryChange(item) {
				this.$refs['cl-form'].open({
					props: {
						title: '兑奖',
						width: '850px',
						'label-width': '120px'
					},

					items: [
						{
							label: '联系人：',
							prop: 'addrName',
							value: item.addrName,
							span: 12,
							component: {
								name: 'el-input',
								attrs: {
									placeholder: '请填写兑奖联系人',
									clearable: true
								}
							},
							rules: {
								required: true,
								message: '联系人不能为空'
							}
						},
						{
							label: '联系电话：',
							prop: 'addrPhone',
							value: item.addrPhone,
							span: 12,
							component: {
								name: 'el-input',
								attrs: {
									placeholder: '请填写联系电话',
									type: 'tel',
									maxLength: 11,
									clearable: true
								}
							},
							rules: {
								required: true,
								message: '联系电话不能为空'
							}
						},
						{
							label: '详细地址：',
							prop: 'address',
							value: item.address,
							component: {
								name: 'el-input',
								attrs: {
									placeholder: '请填写详细地址',
									clearable: true
								}
							},
							rules: {
								required: true,
								message: '详细地址不能为空'
							}
						},
						{
							label: '客服留言：',
							prop: 'remark',
							value: item.remark,
							component: {
								name: 'el-input',
								attrs: {
									placeholder: '请填写客服留言',
									type: 'textarea',
									clearable: true,
									rows: 4
								}
							}
						},
						{
							label: '兑奖状态：',
							prop: 'status',
							value: 1,
							component: {
								name: 'el-radio-group',
								options: [
									{
										label: '未兑奖',
										value: 0
									},
									{
										label: '已兑奖',
										value: 1
									}
								],
								attrs: {
									disabled: true
								}
							},
							rules: {
								required: true,
								message: '请选择兑奖状态'
							},
						},
					],
					on: {
						submit: ({ data, done, close }) => {
							this.$service.interactiveSoft.lotteryActivity.update({
								...data,
								id: item.id
							}).then(() => {
								this.$message.success('保存成功');
								this.refresh();
								close();
							}).catch(err => {
								this.$message.error(err);
								done();
							});
						}
					}
				});
			},
			lotteryCopy(item) {
				this.crud.add();

				this.crud.setForm('name', item.name);
				this.crud.setForm('num', item.num);
				setTimeout(() => {
					this.crud.setForm('pic', item.pic);
				}, 0)
				this.crud.setForm('type', item.type);

				setTimeout(() => {
					if (item.type === 2) {
						this.crud.setData('upsert.items[prop:time].hidden', false);
						this.crud.setData('upsert.items[prop:userCount].hidden', true);
						this.crud.setForm('time', [item.startTime, item.endTime]);
					} else {
						this.crud.setData('upsert.items[prop:time].hidden', true);
						this.crud.setData('upsert.items[prop:userCount].hidden', false);
						this.crud.setForm('userCount', item.userCount);
					}
				}, 0);

				this.crud.setForm('providerIcon', item.providerIcon);
				this.crud.setForm('providerName', item.providerName);
				this.crud.setForm('providerMsg', item.providerMsg);
				this.crud.setForm('linkType', item.linkType);
				this.crud.setForm('link', item.link);
				this.crud.setForm('detailMsg', item.detailMsg);
				this.crud.setForm('robotUserNumber', item.robotUserNumber);
				this.crud.setForm('userId', item.userId);
				this.crud.setForm('level', item.level);
				// this.$confirm('本次操作将创建一条新的抽奖内容', '您确定要复制本条抽奖信息？', {
				// 	confirmButtonText: '立即复制',
				// 	cancelButtonText: '考虑一下',
				// 	type: 'warning'
				// }).then(() => {
				// 	this.$service.interactiveSoft.lotteryActivity
				// 			.copy({
				// 				id: item.id,
				// 			})
				// 			.then(() => {
				// 				this.crud.refresh();
				// 			})
				// 			.catch(err => {
				// 				this.$message.error(err);
				// 			});
				// });
			},
			punchDetail(item) {
				this.$service.interactiveSoft.sign.statistics({
					id: item.id
				}).then(res => {
					if (res.length > 0) {
						this.$refs['cl-form'].open({
							props: {
								title: '报名明细',
								width: '950px',
								'label-width': '0px'
							},
							items: [
								{
									prop: 'punchDetail',
									value: res,
									component: PunchDetail
								},
							],
						});
					} else {
						this.$message.error('暂无信息')
					}
				});
			},
			punchCopy(item) {
				this.crud.add();

				this.crud.setForm('type', item.type);
				this.crud.setForm('startTime', item.startTime);
				this.crud.setForm('amount', item.amount);
				this.crud.setForm('stepNum', item.stepNum);
				// this.$confirm('本次操作将创建一条新的打卡赛', '您确定要复制本条打卡赛信息？', {
				// 	confirmButtonText: '立即复制',
				// 	cancelButtonText: '考虑一下',
				// 	type: 'warning'
				// }).then(() => {
				// 	this.$service.interactiveSoft.sign
				// 			.copy({
				// 				id: item.id,
				// 			})
				// 			.then(() => {
				// 				this.crud.refresh();
				// 			})
				// 			.catch(err => {
				// 				this.$message.error(err);
				// 			});
				// });
			},
			setWechat() {
				this.$service.interactiveSoft.hdyxRiskSetting.wechatMessage().then((res) => {
					this.$refs['cl-form'].open({
						props: {
							title: '客服微信',
							width: '500px',
							'label-width': '120px'
						},
						items: [
							{
								label: '客服微信：',
								prop: 'wechat',
								value: res.wechat,
								component: {
									name: 'el-input',
									attrs: {
										placeholder: '请填写客服微信',
										clearable: true
									}
								},
								rules: {
									required: true,
									message: '客服微信不能为空'
								}
							},
							{
								label: '状态：',
								prop: 'displayWechat',
								value: res.displayWechat,
								component: {
									name: 'el-radio-group',
									options: [
										{
											label: '隐藏',
											value: 0
										},
										{
											label: '显示',
											value: 1
										}
									],
								},
								rules: {
									required: true,
									message: '请选择状态'
								},
							},
						],
						on: {
							submit: ({ data, done, close }) => {
								this.$service.interactiveSoft.hdyxRiskSetting.updateWechatMessage(data).then(() => {
									this.$message.success('保存成功');
									close();
								}).catch(err => {
									this.$message.error(err);
									done();
								});
							}
						}
					});
				}).catch(err => {
					this.$message.error(err);
				});
			}
		}
	};
</script>

<style lang="stylus">
    .page-banner {
        display: flex;

        .left {
            min-width: 230px;
            background-color: #fff;
            margin-right: 10px;

            .title {
                font-size: 15px;
                height: 40px;
                line-height: 40px;
                padding: 0 10px;
                border-bottom: 1px solid #f7f7f7;
                box-sizing: border-box;
            }

            ul {
                overflow: auto;
                height: calc(100% - 40px);

                li {
                    list-style: none;
                    height: 40px;
                    line-height: 40px;
                    padding: 0 10px;
                    font-size: 14px;
                    cursor: pointer;

                    &.active, &:hover {
                        background-color: #eee;
                    }
                }
            }
        }

        .right {
            flex: 1;
        }
    }
    .set-wechat {
        padding 6px 0 0 0
    }
</style>
